#!/bin/bash

source /etc/profile
day=$1
path=$(cd $(dirname $0);pwd)
source ${path}/configs/mysql_config
tables="nas_analysis_conversion nas_analysis_event nas_analysis_forecast nas_behaviour_entryurl nas_behaviour_exiturl nas_behaviour_innersearch nas_behaviour_innersearchword nas_behaviour_visitchannel nas_behaviour_visitpath nas_behaviour_visiturl nas_overview nas_referer_all nas_tools_ip nas_tools_keyword nas_visitor_area nas_visitor_device nas_visitor_language nas_visitor_overview nas_visitor_overview_hour"
sql='delete from %s where day="%s\"'
esql=$(python -c "l='${tables}'.split();print ';'.join(map(lambda x:'${sql}' % (x,'${day}'),l))")
mysql -h${host} -P${port} -u${user} -p${password} -e "use ${db};${esql}"